Skip to content

feat: unnest transform#78

Merged
close2 merged 3 commits intomasterfrom
CL/v8
Mar 19, 2026
Merged

feat: unnest transform#78
close2 merged 3 commits intomasterfrom
CL/v8

Conversation

@close2
Copy link
Owner

@close2 close2 commented Mar 17, 2026

fixes #77

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #77 by changing the library’s stream transformation model so CSV decoding/encoding streams emit one row per event, eliminating the extra List<List<...>> nesting that appeared when using Stream.transform(...).toList() after upgrading to v7.

Changes:

  • Refactors CsvDecoder and CsvEncoder to be StreamTransformerBase implementations (row-per-event) while keeping batch convert(...)-style APIs.
  • Introduces Csv as the primary API (with deprecated CsvCodec typedef) and adds asCodec() as a dart:convert Codec adapter for .fuse() use cases.
  • Updates tests, examples, benchmarks, docs, changelog, and bumps package version to 8.0.0.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/src/csv_decoder.dart Refactors decoding to emit one row per stream event while preserving batch decode via convert().
lib/src/csv_encoder.dart Refactors encoding to accept one row per stream event and preserves batch encode via convert().
lib/src/csv_codec.dart Replaces CsvCodec class with Csv, adds encode/decode helpers and introduces asCodec() adapter.
lib/csv.dart Updates top-level csv/excel instances to use Csv.
test/csv_test.dart Updates chunked conversion tests to assert flat row emission and new encoder input types.
test/small_chunk_test.dart Updates expectations to match row-per-event decoding (no manual flattening).
test/parse_headers_test.dart Updates to construct Csv(parseHeaders: true) and keeps header parsing behavior tests.
test/split_escape_test.dart Updates chunked decoding sink setup to collect row events directly.
test/split_crlf_test.dart Same as above for CRLF chunking scenarios.
test/multi_char_delim_test.dart Same as above for multi-character delimiter chunking scenarios.
example/csv_fuse_example.dart Updates .fuse() example to use csv.asCodec() as the supported path.
benchmark/benchmark_csv.dart Updates benchmark streams to use per-row events and uses asCodec() for fuse benchmarking.
README.md Documents v8 upgrade, stream row-per-event behavior, and explains the Codec/asCodec() tradeoff.
CHANGELOG.md Adds v8.0.0 entry describing the fix and breaking changes.
pubspec.yaml Bumps version to 8.0.0 and updates package description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@close2 close2 requested a review from Copilot March 18, 2026 20:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restructures the CSV API to fix issue #77 (“extra layer of []” when using stream.transform(csv.decoder).toList()) by making the decoder/encoder true stream transformers that emit one row per stream event, while preserving a dart:convert Codec pathway via asCodec().

Changes:

  • Refactors CsvDecoder/CsvEncoder into StreamTransformerBase implementations (one row per event) to eliminate List<List<List<dynamic>>> nesting in stream usage.
  • Renames CsvCodecCsv (with deprecated CsvCodec typedef) and adds Csv.asCodec() to support Codec.fuse() and other dart:convert-only APIs.
  • Updates docs, examples, benchmarks, and tests to the new stream semantics and asCodec() usage; adds new asCodec() test coverage.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/src/csv_decoder.dart Emits one decoded row per stream event; keeps batch convert() returning all rows.
lib/src/csv_encoder.dart Emits one encoded row fragment per stream event; keeps batch convert() for full CSV output.
lib/src/csv_codec.dart Introduces Csv as primary API, adds asCodec() adapter, deprecates CsvCodec name.
lib/csv.dart Updates exported defaults (csv, excel) to be Csv instances.
README.md Documents v8 upgrade, stream behavior, and asCodec() rationale/usage.
CHANGELOG.md Adds v8.0.0 breaking changes and notes the stream nesting fix.
pubspec.yaml Bumps version to 8.0.0 and updates package description.
example/csv_fuse_example.dart Updates fuse example to use csv.asCodec().
benchmark/benchmark_csv.dart Updates benchmark to stream per-row events and use asCodec() for fuse benchmark.
test/csv_test.dart Updates chunked conversion tests to new flat (row-per-event) stream behavior.
test/small_chunk_test.dart Removes now-unnecessary unnesting in expectations for stream decoding.
test/parse_headers_test.dart Migrates to Csv(parseHeaders: true) API.
test/split_escape_test.dart Updates chunked sink usage for per-row emission.
test/split_crlf_test.dart Updates chunked sink usage for per-row emission.
test/multi_char_delim_test.dart Updates chunked sink usage for per-row emission.
test/as_codec_test.dart Adds comprehensive tests for asCodec() behavior and batching controls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@close2 close2 merged commit 117f64d into master Mar 19, 2026
6 checks passed
@close2 close2 deleted the CL/v8 branch March 19, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openRead returns one more layer of []

2 participants